1. Field of the Invention
The present invention generally relates to methods and systems for dynamic and default binding of attributes in declarative environment, such as Extensible Markup Language (XML).
2. Description of the Related Art
Extensible Markup Language (XML) is a standard for creating languages that meet the XML criteria. It is extensible, because data represented according to the XML standard may be marked up in any manner desired. For example, unlike Hyper Text Markup Language (HTML), the developer is free to add previously undefined tags to an XML document and an XML parser will be able to read the document. An XML document is a structured file. More particularly, XML documents are structured as hierarchies of information.
XML document contain one or more elements (which must adhere to a limited set of rules), the boundaries of which are either delimited by start-tags and end-tags, or, for empty elements, by an empty-element tag. Each element has a type, identified by name, sometimes called its “generic identifier” (GI), and may have a set of attribute specifications. Each attribute may be data bound to simple text, to a data source inside an application or to, for example, a JAVA method that, when called, returns data. The attribute or attributes serve to describe the element and do not further specify the parent-child relationship of the element within the document. Each attribute specification has a name and a value. Attributes, therefore, are name/value pairs that may be associated with an element. Attributes provide additional information about an element and may be used to attach characteristics or properties to the elements of a document. An element may have more than one attribute. Attributes are represented by an attribute name followed by an equal sign and the attribute value in quotation marks, such as:
<TITLE> <LANGUAGE lang=“US-English”>Oracle11i Server Concepts </LANGUAGE> </TITLE>
In this example, the TITLE element contains another element, the LANGUAGE element. The LANGUAGE element has one attribute “lang”, which evaluates to the value of “US-English”. The contents of the TITLE element are the string “Oracle 11i Server Concepts”.
Declarative languages such as XML commonly utilize document model against which the hierarchically structured electronic document are validated by a parser. The model document may be a Document Type Definition (DTD) syntax or an XML Schema, for example. XML Schemas, for example, are defined at www.w3.org. Section 3.3.2 of the W3C XML specification describes the manner in which an attribute is declared in a Schema. A default value for an attribute may be declared in a Schema and such declared default will be used when that attribute is not declared during usage. Indeed, according to this section, when an XML processor encounters an omitted value, it is to behave as though the attribute were present with the declared default value. For example, in the document model—such as an XML Schema or Document Type Definition (DTD) that is used to validate the current document and to define the elements thereof, an exemplary metasyntactical element <foo> may be defined. In the document model, it may be specified that if the attribute “bar” of the element <foo> is not used, then it defaults to some value. In the XML document, then the expression <foo bar=“example”> the attribute “bar” would be evaluated to “example”, as expected. However, if the element <foo> is used alone (i.e., without the attribute “bar”), then the “bar” attribute would resolve to some value when it isn't explicitly specified. As noted above, the normal defaulting mechanism of XML forces the default value to be specified in the document model (i.e., the Schema or DTD) for all usages.
It is not always practical to hard code the value of an attribute in the document model. For example, the specific value of an attribute may be located in a remote data source and the value of the attribute may be declared as the location of the data source. Moreover, the location of the data source containing the value of the attribute may have been incorrectly declared, which results in a failure of the attribute evaluation (i.e., the process of assigning a value to the attribute name). Alternatively, the data source itself (whether a method returning a value, a remote server or other data resource) may fail, be unavailable or otherwise unable to provide the specified value of the attribute. In such cases, the attribute evaluation also fails. What are needed, therefore, are methods and systems for handling the case wherein the attribute evaluation fails, for whatever reason. What are also needed are mechanisms for specifying default values outside of the document model; that is, mechanisms that enable the default values of attributes to be changed from use to use, such as in more than one namespace. What are also needed are methods and systems for dynamic fallback attribute binding in a declarative environment, such as, for example, XML.